package com.itlong.cloud.enumerate.ecode;

import lombok.Getter;
import lombok.Setter;

/** 错误码定义
 * @author cuiduanwu
 * @create 2017--20 14:37
 */
public class ErrorCode {

    @Setter
    @Getter
    private Integer mainCode ;

    @Setter
    @Getter
    private Integer subCode;

    @Setter
    @Getter
    private String codeMsg;

    public ErrorCode(){}

    /** 主错误码与错误信息构造函数
     *
     * @param mainCode
     */
    public ErrorCode(Integer mainCode, String codeMsg) {
        this.setMainCode(mainCode);
        this.setSubCode(0);
        this.setCodeMsg(codeMsg);
    }

    /** 全参构造函数
     *
     * @param mainCode
     * @param subCode
     */
    public ErrorCode(Integer mainCode, Integer subCode, String codeMsg){
        this.setMainCode(mainCode);
        this.setSubCode(subCode);
        this.setCodeMsg(codeMsg);
    }



    /** 计算最终的错误码值
     * 主错误码*1000+子错误码
     * @return
     */
    public Integer getErrorValue(){
        return  this.getMainCode()*1000+this.getSubCode();
    }
}
